home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMoviePTGate.py < prev    next >
Text File  |  2008-11-17  |  4KB  |  133 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMoviePTGate.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2005-2007 Vasco Nunes, Piotr Ozarowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27.  
  28. plugin_name = "PTGate"
  29. plugin_description = "Cinema PTGate"
  30. plugin_url = "www.cinema.ptgate.pt"
  31. plugin_language = _("Portuguese")
  32. plugin_author = "Vasco Nunes"
  33. plugin_author_email="<vasco.m.nunes@gmail.com>"
  34. plugin_version = "0.4.1"
  35.  
  36. class Plugin(movie.Movie):
  37.     def __init__(self, id):
  38.         self.encode='iso-8859-1'
  39.         self.movie_id = id
  40.         self.url = "http://cinema.ptgate.pt/filme.php?code=" + str(self.movie_id)
  41.  
  42.     def get_image(self):
  43.         self.image_url = "http://cinema.ptgate.pt/Movies/" + str(self.movie_id)+".jpg"
  44.  
  45.     def get_o_title(self):
  46.         self.o_title = string.capwords(gutils.trim(self.page,"<b class=title>","</b><br>") )
  47.  
  48.     def get_title(self):
  49.         self.title = string.capwords(gutils.trim(self.page,"class=subtitle>","</b><br>") )
  50.  
  51.     def get_director(self):
  52.         self.director = gutils.trim(self.page,"<b>realiza├º├úo</b><br>","<br><br><b>")
  53.  
  54.     def get_plot(self):
  55.         self.plot = gutils.trim(self.page,"<b>sinopse</b><br>","<br><br>")
  56.         self.plot = string.replace(self.plot,"'","\"")
  57.         self.plot = string.replace(self.plot,"'","\"")
  58.  
  59.     def get_year(self):
  60.         self.year = gutils.trim(self.page,"<br><b>ano</b><br>","<br><br><b>pa")
  61.  
  62.     def get_runtime(self):
  63.         self.runtime = ""
  64.  
  65.     def get_genre(self):
  66.         self.genre = gutils.trim(self.page,"nero</b><br>","<br><br><b>realiza")
  67.         self.genre = string.replace(self.genre," | ",", ")
  68.  
  69.     def get_cast(self):
  70.         self.cast = ""
  71.         self.cast = gutils.trim(self.page,"pretes</b><br>","<br><br><b>data de estreia</b><br>")
  72.         self.cast = string.replace(self.cast,"<br> ","\n")
  73.         self.cast = string.replace(self.cast,"<br>", "\n")
  74.         self.cast = gutils.strip_tags(self.cast)
  75.  
  76.     def get_classification(self):
  77.         self.classification = ""
  78.  
  79.     def get_studio(self):
  80.         self.studio = ""
  81.  
  82.     def get_o_site(self):
  83.         self.o_site = gutils.trim(self.page,"tio oficial</b><br><a class=external href='", "'>")
  84.  
  85.     def get_site(self):
  86.         self.site = gutils.trim(self.page,"<br><b>imdb</b><br><a class=external href='", "'>www.imdb.com")
  87.  
  88.     def get_trailer(self):
  89.         self.trailer = gutils.trim(self.page,"trailer</b><br><a class=external href='", "'>visionar")
  90.  
  91.     def get_country(self):
  92.         self.country = gutils.trim(self.page,"s</b><br>","<br><br><b>g")
  93.         
  94.     def get_notes(self):
  95.         self.notes = gutils.trim(self.page,"pr├⌐mios e nomea├º├╡es</b><br><b>", "<td width=6 background='Images/group_r.gif'")
  96.         self.notes = gutils.strip_tags(self.notes)
  97.  
  98.     def get_rating(self):
  99.         tmp=gutils.trim(self.page,"'Images/mstar",".gif")
  100.         if(tmp):
  101.             self.rating = float(tmp)
  102.             if (self.rating>10):
  103.                 self.rating = int(self.rating/10)
  104.                 self.rating = self.rating*2
  105.         else:
  106.             self.rating=""
  107.  
  108. class SearchPlugin(movie.SearchMovie):
  109.     def __init__(self):
  110.         self.original_url_search    = "http://cinema.ptgate.pt/pesquisa-filme.php?titulo="
  111.         self.translated_url_search    = "http://cinema.ptgate.pt/pesquisa-filme.php?titulo="
  112.         self.encode='iso-8859-1'
  113.  
  114.     def search(self,parent_window):
  115.         self.open_search(parent_window)
  116.         self.sub_search()
  117.         return self.page
  118.  
  119.     def sub_search(self):
  120.         self.page = gutils.trim(self.page,"<!-- DISPLAY RESULTS -->", "<!-- /DISPLAY RESULTS -->")
  121.  
  122.     def get_searches(self):
  123.         elements = string.split(self.page,"</td><td>")
  124.         self.number_results = elements[-1]
  125.  
  126.         if (len(elements[0])):
  127.             for element in elements:
  128.                 element = string.replace(element,"</a>","")
  129.                 self.ids.append(gutils.trim(element,"?code=","'>"))
  130.                 self.titles.append(gutils.convert_entities(gutils.trim(element,"'>","</td><td width=6")))
  131.         else:
  132.             self.number_results = 0
  133.